@@ -144,13 +144,13 @@ def getBlock(self, block_identifier, full_transactions=False):
144144 if_number = 'eth_getBlockByNumber' ,
145145 )
146146
147- try :
148- return self .web3 .manager .request_blocking (
149- method ,
150- [block_identifier , full_transactions ],
151- )
152- except ValueError :
147+ result = self .web3 .manager .request_blocking (
148+ method ,
149+ [block_identifier , full_transactions ],
150+ )
151+ if result is None :
153152 raise BlockNotFound (f"Block with id: { block_identifier } not found." )
153+ return result
154154
155155 def getBlockTransactionCount (self , block_identifier ):
156156 """
@@ -163,13 +163,13 @@ def getBlockTransactionCount(self, block_identifier):
163163 if_hash = 'eth_getBlockTransactionCountByHash' ,
164164 if_number = 'eth_getBlockTransactionCountByNumber' ,
165165 )
166- try :
167- return self .web3 .manager .request_blocking (
168- method ,
169- [block_identifier ],
170- )
171- except ValueError :
166+ result = self .web3 .manager .request_blocking (
167+ method ,
168+ [block_identifier ],
169+ )
170+ if result is None :
172171 raise BlockNotFound (f"Block with id: { block_identifier } not found." )
172+ return result
173173
174174 def getUncleCount (self , block_identifier ):
175175 """
@@ -182,13 +182,13 @@ def getUncleCount(self, block_identifier):
182182 if_hash = 'eth_getUncleCountByBlockHash' ,
183183 if_number = 'eth_getUncleCountByBlockNumber' ,
184184 )
185- try :
186- return self .web3 .manager .request_blocking (
187- method ,
188- [block_identifier ],
189- )
190- except ValueError :
185+ result = self .web3 .manager .request_blocking (
186+ method ,
187+ [block_identifier ],
188+ )
189+ if result is None :
191190 raise BlockNotFound (f"Block with id: { block_identifier } not found." )
191+ return result
192192
193193 def getUncleByBlock (self , block_identifier , uncle_index ):
194194 """
@@ -201,24 +201,24 @@ def getUncleByBlock(self, block_identifier, uncle_index):
201201 if_hash = 'eth_getUncleByBlockHashAndIndex' ,
202202 if_number = 'eth_getUncleByBlockNumberAndIndex' ,
203203 )
204- try :
205- return self .web3 .manager .request_blocking (
206- method ,
207- [block_identifier , uncle_index ],
208- )
209- except ValueError :
204+ result = self .web3 .manager .request_blocking (
205+ method ,
206+ [block_identifier , uncle_index ],
207+ )
208+ if result is None :
210209 raise BlockNotFound (
211210 f"Uncle at index: { uncle_index } of block with id: { block_identifier } not found."
212211 )
212+ return result
213213
214214 def getTransaction (self , transaction_hash ):
215- try :
216- return self .web3 .manager .request_blocking (
217- "eth_getTransactionByHash" ,
218- [transaction_hash ],
219- )
220- except ValueError :
215+ result = self .web3 .manager .request_blocking (
216+ "eth_getTransactionByHash" ,
217+ [transaction_hash ],
218+ )
219+ if result is None :
221220 raise TransactionNotFound (f"Transaction with hash: { transaction_hash } not found." )
221+ return result
222222
223223 @deprecated_for ("w3.eth.getTransactionByBlock" )
224224 def getTransactionFromBlock (self , block_identifier , transaction_index ):
@@ -239,16 +239,16 @@ def getTransactionByBlock(self, block_identifier, transaction_index):
239239 if_hash = 'eth_getTransactionByBlockHashAndIndex' ,
240240 if_number = 'eth_getTransactionByBlockNumberAndIndex' ,
241241 )
242- try :
243- return self .web3 .manager .request_blocking (
244- method ,
245- [block_identifier , transaction_index ],
246- )
247- except ValueError :
242+ result = self .web3 .manager .request_blocking (
243+ method ,
244+ [block_identifier , transaction_index ],
245+ )
246+ if result is None :
248247 raise TransactionNotFound (
249248 f"Transaction index: { transaction_index } "
250249 f"on block id: { block_identifier } not found."
251250 )
251+ return result
252252
253253 def waitForTransactionReceipt (self , transaction_hash , timeout = 120 ):
254254 try :
@@ -262,13 +262,13 @@ def waitForTransactionReceipt(self, transaction_hash, timeout=120):
262262 )
263263
264264 def getTransactionReceipt (self , transaction_hash ):
265- try :
266- return self .web3 .manager .request_blocking (
267- "eth_getTransactionReceipt" ,
268- [transaction_hash ],
269- )
270- except ValueError :
265+ result = self .web3 .manager .request_blocking (
266+ "eth_getTransactionReceipt" ,
267+ [transaction_hash ],
268+ )
269+ if result is None :
271270 raise TransactionNotFound (f"Transaction with hash: { transaction_hash } not found." )
271+ return result
272272
273273 def getTransactionCount (self , account , block_identifier = None ):
274274 if block_identifier is None :
0 commit comments