This repository was archived by the owner on Sep 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -380,6 +380,19 @@ def chain_id(self) -> Optional[int]:
380380 ...
381381
382382
383+ class LegacyTransactionFieldsAPI (TransactionFieldsAPI ):
384+ @property
385+ @abstractmethod
386+ def v (self ) -> int :
387+ """
388+ In old transactions, this v field combines the y_parity bit and the
389+ chain ID. All new usages should prefer accessing those fields directly.
390+ But if you must access the original v, then you can cast to this API
391+ first (after checking that type_id is None).
392+ """
393+ ...
394+
395+
383396class UnsignedTransactionAPI (BaseTransactionAPI ):
384397
385398 """
Original file line number Diff line number Diff line change 2424from eth .abc import (
2525 BaseTransactionAPI ,
2626 ComputationAPI ,
27+ LegacyTransactionFieldsAPI ,
2728 SignedTransactionAPI ,
2829 TransactionBuilderAPI ,
2930 TransactionFieldsAPI ,
@@ -103,13 +104,21 @@ def is_signature_valid(self) -> bool:
103104 return True
104105
105106
106- class BaseTransaction (BaseTransactionFields , SignedTransactionMethods , TransactionBuilderAPI ):
107+ class BaseTransaction (
108+ LegacyTransactionFieldsAPI ,
109+ BaseTransactionFields ,
110+ SignedTransactionMethods ,
111+ TransactionBuilderAPI ):
107112 # "Legacy" transactions implemented by BaseTransaction are a combination of
108113 # the transaction codec (TransactionBuilderAPI) *and* the transaction
109114 # object (SignedTransactionAPI). In a multi-transaction-type world, that
110115 # becomes less desirable, and that responsibility splits up. See Berlin
111116 # transactions, for example.
112117
118+ # Note that it includes at least one legacy field (v) that is not
119+ # explicitly accessible in new transaction types. See the v docstring in
120+ # LegacyTransactionFieldsAPI for more.
121+
113122 # this is duplicated to make the rlp library happy, otherwise it complains
114123 # about no fields being defined but inheriting from multiple `Serializable`
115124 # bases.
Original file line number Diff line number Diff line change 1+ Add new LegacyTransactionFieldsAPI, with a v field for callers that want to access v directly.
You can’t perform that action at this time.
0 commit comments