Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 07a1884

Browse files
authored
Merge pull request #1996 from carver/type-id-on-legacy
Make type_id accessible on all transactions
2 parents e5b21ae + 04e3db1 commit 07a1884

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

eth/abc.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,17 @@ def y_parity(self) -> int:
534534
"""
535535
...
536536

537+
type_id: Optional[int]
538+
"""
539+
The type of EIP-2718 transaction
540+
541+
Each EIP-2718 transaction includes a type id (which is the leading
542+
byte, as encoded).
543+
544+
If this transaction is a legacy transaction, that it has no type. Then,
545+
type_id will be None.
546+
"""
547+
537548
# +-------------------------------------------------------------+
538549
# | API that must be implemented by all Transaction subclasses. |
539550
# +-------------------------------------------------------------+

eth/rlp/transactions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ def hash(self) -> Hash32:
7676

7777

7878
class SignedTransactionMethods(BaseTransactionMethods, SignedTransactionAPI):
79+
type_id: Optional[int] = None
80+
7981
@cached_property
8082
def sender(self) -> Address:
8183
return self.get_sender()

eth/vm/forks/berlin/transactions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ def decode(cls, payload: bytes) -> SignedTransactionAPI:
221221

222222

223223
class TypedTransaction(SignedTransactionMethods, SignedTransactionAPI, TransactionDecoderAPI):
224-
type_id: int
225224
rlp_type = Binary(min_length=1) # must have at least one byte for the type
226225
_inner: SignedTransactionAPI
227226

newsfragments/1996.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Expose a ``type_id`` on all transactions. It is ``None`` for legacy transactions.

0 commit comments

Comments
 (0)