4444 async_fill_transaction_defaults ,
4545)
4646from web3 ._utils .batching import (
47- is_batching_context ,
47+ BatchRequestInformation ,
4848)
4949from web3 ._utils .compat import (
5050 TypeAlias ,
@@ -178,10 +178,8 @@ def call_contract_function(
178178 if abi_callable ["type" ] == "function" :
179179 output_types = get_abi_output_types (abi_callable )
180180
181- w3 .provider
182- if is_batching_context ():
183- BatchingReturnData : TypeAlias = Tuple [Tuple [RPCEndpoint , Any ], Tuple [Any , ...]]
184- request_information = tuple (cast (BatchingReturnData , return_data ))
181+ if w3 .provider ._is_batching :
182+ request_information = tuple (cast (BatchRequestInformation , return_data ))
185183 method_and_params = request_information [0 ]
186184
187185 # append return data formatting to result formatters
@@ -477,7 +475,7 @@ async def async_call_contract_function(
477475 if fn_abi ["type" ] == "function" :
478476 output_types = get_abi_output_types (fn_abi )
479477
480- if is_batching_context () :
478+ if async_w3 . provider . _is_batching :
481479 contract_call_return_data_formatter = format_contract_call_return_data_curried (
482480 async_w3 ,
483481 decode_tuples ,
@@ -486,33 +484,24 @@ async def async_call_contract_function(
486484 normalizers ,
487485 output_types ,
488486 )
489- if async_w3 .provider .has_persistent_connection :
490- # get the current request id
491- provider = cast ("PersistentConnectionProvider" , async_w3 .provider )
492- current_request_id = provider ._batch_request_counter - 1
493- provider ._request_processor .append_result_formatter_for_request (
494- current_request_id , contract_call_return_data_formatter
495- )
496- else :
497- BatchingReturnData : TypeAlias = Tuple [
498- Tuple [RPCEndpoint , Any ], Tuple [Any , ...]
499- ]
500- request_information = tuple (cast (BatchingReturnData , return_data ))
501- method_and_params = request_information [0 ]
502-
503- # append return data formatter to result formatters
504- current_response_formatters = request_information [1 ]
505- current_result_formatters = current_response_formatters [0 ]
506- updated_result_formatters = compose (
507- contract_call_return_data_formatter ,
508- current_result_formatters ,
509- )
510- response_formatters = (
511- updated_result_formatters , # result formatters
512- current_response_formatters [1 ], # error formatters
513- current_response_formatters [2 ], # null result formatters
514- )
515- return (method_and_params , response_formatters )
487+
488+ BatchingReturnData : TypeAlias = Tuple [Tuple [RPCEndpoint , Any ], Tuple [Any , ...]]
489+ request_information = tuple (cast (BatchingReturnData , return_data ))
490+ method_and_params = request_information [0 ]
491+
492+ # append return data formatter to result formatters
493+ current_response_formatters = request_information [1 ]
494+ current_result_formatters = current_response_formatters [0 ]
495+ updated_result_formatters = compose (
496+ contract_call_return_data_formatter ,
497+ current_result_formatters ,
498+ )
499+ response_formatters = (
500+ updated_result_formatters , # result formatters
501+ current_response_formatters [1 ], # error formatters
502+ current_response_formatters [2 ], # null result formatters
503+ )
504+ return (method_and_params , response_formatters )
516505
517506 return return_data
518507
0 commit comments