Skip to content

Commit

Permalink
Async changes related to 999ef9a
Browse files Browse the repository at this point in the history
  • Loading branch information
fselmo committed Nov 27, 2024
1 parent 999ef9a commit bf62ecf
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions web3/contract/async_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -720,34 +723,29 @@ 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)

if self.abi:
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,
transaction=transaction,
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,
Expand Down

0 comments on commit bf62ecf

Please sign in to comment.