29
29
from typing import Final , Literal , SupportsInt , Tuple
30
30
31
31
from ethereum_types .numeric import U256 , Uint
32
+ from typing_extensions import override
32
33
33
34
34
35
@functools .total_ordering
@@ -68,6 +69,7 @@ class ForkCriteria(ABC):
68
69
69
70
_internal : Tuple [int , int ]
70
71
72
+ @override
71
73
def __eq__ (self , other : object ) -> bool :
72
74
"""
73
75
Equality for fork criteria.
@@ -92,6 +94,7 @@ def __lt__(self, other: object) -> bool:
92
94
return self ._internal < other ._internal
93
95
return NotImplemented
94
96
97
+ @override
95
98
def __hash__ (self ) -> int :
96
99
"""
97
100
Compute a hash for this instance, so it can be stored in dictionaries.
@@ -108,6 +111,7 @@ def check(self, block_number: Uint, timestamp: U256) -> bool:
108
111
"""
109
112
raise NotImplementedError ()
110
113
114
+ @override
111
115
@abstractmethod
112
116
def __repr__ (self ) -> str :
113
117
"""
@@ -127,9 +131,11 @@ class ByBlockNumber(ForkCriteria):
127
131
"""
128
132
129
133
def __init__ (self , block_number : SupportsInt ):
134
+ super ().__init__ ()
130
135
self ._internal = (ForkCriteria .BLOCK_NUMBER , int (block_number ))
131
136
self .block_number = Uint (int (block_number ))
132
137
138
+ @override
133
139
def check (self , block_number : Uint , timestamp : U256 ) -> bool :
134
140
"""
135
141
Check whether the block number has been reached.
@@ -141,6 +147,7 @@ def check(self, block_number: Uint, timestamp: U256) -> bool:
141
147
"""
142
148
return block_number >= self .block_number
143
149
150
+ @override
144
151
def __repr__ (self ) -> str :
145
152
"""
146
153
String representation of this object.
@@ -159,9 +166,11 @@ class ByTimestamp(ForkCriteria):
159
166
"""
160
167
161
168
def __init__ (self , timestamp : SupportsInt ):
169
+ super ().__init__ ()
162
170
self ._internal = (ForkCriteria .TIMESTAMP , int (timestamp ))
163
171
self .timestamp = U256 (timestamp )
164
172
173
+ @override
165
174
def check (self , block_number : Uint , timestamp : U256 ) -> bool :
166
175
"""
167
176
Check whether the timestamp has been reached.
@@ -173,6 +182,7 @@ def check(self, block_number: Uint, timestamp: U256) -> bool:
173
182
"""
174
183
return timestamp >= self .timestamp
175
184
185
+ @override
176
186
def __repr__ (self ) -> str :
177
187
"""
178
188
String representation of this object.
@@ -186,14 +196,17 @@ class Unscheduled(ForkCriteria):
186
196
"""
187
197
188
198
def __init__ (self ) -> None :
199
+ super ().__init__ ()
189
200
self ._internal = (ForkCriteria .UNSCHEDULED , 0 )
190
201
202
+ @override
191
203
def check (self , block_number : Uint , timestamp : U256 ) -> Literal [False ]:
192
204
"""
193
205
Unscheduled forks never occur; always returns `False`.
194
206
"""
195
207
return False
196
208
209
+ @override
197
210
def __repr__ (self ) -> str :
198
211
"""
199
212
String representation of this object.
0 commit comments