Skip to content

Commit 6696446

Browse files
docs: update transaction types to use constants (#12301)
* Update transaction types to use constants * Update mod.rs * Update mod.rs
1 parent 774671b commit 6696446

File tree

1 file changed

+9
-5
lines changed
  • crates/anvil/core/src/eth/transaction

1 file changed

+9
-5
lines changed

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
use alloy_consensus::{
33
Receipt, ReceiptEnvelope, ReceiptWithBloom, Signed, Transaction, TxEip1559, TxEip2930,
44
TxEnvelope, TxLegacy, TxReceipt, Typed2718,
5+
constants::{
6+
EIP1559_TX_TYPE_ID, EIP2930_TX_TYPE_ID, EIP4844_TX_TYPE_ID, EIP7702_TX_TYPE_ID,
7+
LEGACY_TX_TYPE_ID,
8+
},
59
transaction::{
610
Recovered, TxEip7702,
711
eip4844::{TxEip4844, TxEip4844Variant, TxEip4844WithSidecar},
@@ -436,7 +440,7 @@ impl PendingTransaction {
436440
gas_priority_fee: None,
437441
gas_limit: *gas_limit,
438442
access_list: vec![].into(),
439-
tx_type: 0,
443+
tx_type: LEGACY_TX_TYPE_ID,
440444
..Default::default()
441445
})
442446
}
@@ -463,7 +467,7 @@ impl PendingTransaction {
463467
gas_priority_fee: None,
464468
gas_limit: *gas_limit,
465469
access_list: access_list.clone(),
466-
tx_type: 1,
470+
tx_type: EIP2930_TX_TYPE_ID,
467471
..Default::default()
468472
})
469473
}
@@ -491,7 +495,7 @@ impl PendingTransaction {
491495
gas_priority_fee: Some(*max_priority_fee_per_gas),
492496
gas_limit: *gas_limit,
493497
access_list: access_list.clone(),
494-
tx_type: 2,
498+
tx_type: EIP1559_TX_TYPE_ID,
495499
..Default::default()
496500
})
497501
}
@@ -523,7 +527,7 @@ impl PendingTransaction {
523527
blob_hashes: blob_versioned_hashes.clone(),
524528
gas_limit: *gas_limit,
525529
access_list: access_list.clone(),
526-
tx_type: 3,
530+
tx_type: EIP4844_TX_TYPE_ID,
527531
..Default::default()
528532
})
529533
}
@@ -552,7 +556,7 @@ impl PendingTransaction {
552556
gas_priority_fee: Some(*max_priority_fee_per_gas),
553557
gas_limit: *gas_limit,
554558
access_list: access_list.clone(),
555-
tx_type: 4,
559+
tx_type: EIP7702_TX_TYPE_ID,
556560
..Default::default()
557561
};
558562
tx.set_signed_authorization(authorization_list.clone());

0 commit comments

Comments
 (0)