diff --git a/web3/contract/async_contract.py b/web3/contract/async_contract.py index b661f41e72..d77d476a50 100644 --- a/web3/contract/async_contract.py +++ b/web3/contract/async_contract.py @@ -23,7 +23,6 @@ abi_to_signature, get_abi_input_names, get_abi_input_types, - get_all_function_abis, ) from eth_utils.toolz import ( partial, @@ -588,7 +587,11 @@ def __init__(self, address: Optional[ChecksumAddress] = None) -> None: self.abi, self.w3, self.address, decode_tuples=self.decode_tuples ) self.caller = AsyncContractCaller( - self.abi, self.w3, self.address, decode_tuples=self.decode_tuples + self.abi, + self.w3, + self.address, + decode_tuples=self.decode_tuples, + contract_functions=self.functions, ) self.events = AsyncContractEvents(self.abi, self.w3, self.address) self.fallback = AsyncContract.get_fallback_function( @@ -720,6 +723,7 @@ def __init__( block_identifier: BlockIdentifier = None, ccip_read_enabled: Optional[bool] = None, decode_tuples: Optional[bool] = False, + contract_functions: Optional[AsyncContractFunctions] = None, ) -> None: super().__init__(abi, w3, address, decode_tuples=decode_tuples) @@ -727,18 +731,13 @@ def __init__( if transaction is None: transaction = {} - self._functions = get_all_function_abis(self.abi) - - for func in self._functions: - abi_signature = abi_to_signature(func) - fn = AsyncContractFunction.factory( - abi_signature, - w3=w3, - contract_abi=self.abi, - address=self.address, - decode_tuples=decode_tuples, + if contract_functions is None: + contract_functions = AsyncContractFunctions( + abi, w3, address, decode_tuples=decode_tuples ) + self._functions = contract_functions._functions + for fn in contract_functions.__iter__(): caller_method = partial( self.call_function, fn, @@ -746,8 +745,7 @@ def __init__( block_identifier=block_identifier, ccip_read_enabled=ccip_read_enabled, ) - - setattr(self, abi_signature, caller_method) + setattr(self, str(fn.abi_element_identifier), caller_method) def __call__( self,