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]:
380
380
...
381
381
382
382
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
+
383
396
class UnsignedTransactionAPI (BaseTransactionAPI ):
384
397
385
398
"""
Original file line number Diff line number Diff line change 24
24
from eth .abc import (
25
25
BaseTransactionAPI ,
26
26
ComputationAPI ,
27
+ LegacyTransactionFieldsAPI ,
27
28
SignedTransactionAPI ,
28
29
TransactionBuilderAPI ,
29
30
TransactionFieldsAPI ,
@@ -103,13 +104,21 @@ def is_signature_valid(self) -> bool:
103
104
return True
104
105
105
106
106
- class BaseTransaction (BaseTransactionFields , SignedTransactionMethods , TransactionBuilderAPI ):
107
+ class BaseTransaction (
108
+ LegacyTransactionFieldsAPI ,
109
+ BaseTransactionFields ,
110
+ SignedTransactionMethods ,
111
+ TransactionBuilderAPI ):
107
112
# "Legacy" transactions implemented by BaseTransaction are a combination of
108
113
# the transaction codec (TransactionBuilderAPI) *and* the transaction
109
114
# object (SignedTransactionAPI). In a multi-transaction-type world, that
110
115
# becomes less desirable, and that responsibility splits up. See Berlin
111
116
# transactions, for example.
112
117
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
+
113
122
# this is duplicated to make the rlp library happy, otherwise it complains
114
123
# about no fields being defined but inheriting from multiple `Serializable`
115
124
# 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