From 81d1c89684340011e66fd834f74b160cd1dc1c35 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Fri, 2 Aug 2024 10:48:24 -0500 Subject: [PATCH] refactor: method share fix --- src/ape/contracts/base.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/ape/contracts/base.py b/src/ape/contracts/base.py index 2e97dd7147..24b31bc682 100644 --- a/src/ape/contracts/base.py +++ b/src/ape/contracts/base.py @@ -255,9 +255,7 @@ def decode_input(self, calldata: bytes) -> tuple[str, dict[str, Any]]: raise err - -class ContractCallHandler(ContractMethodHandler): - def __call__(self, *args, **kwargs) -> Any: + def _validate_is_contract(self): if not self.contract.is_contract: raise ContractNotFoundError( self.contract.address, @@ -265,6 +263,12 @@ def __call__(self, *args, **kwargs) -> Any: self.provider.network_choice, ) + +class ContractCallHandler(ContractMethodHandler): + def __call__(self, *args, **kwargs) -> Any: + if not self.contract.is_contract: + self._validate_is_contract() + selected_abi = _select_method_abi(self.abis, args) arguments = self.conversion_manager.convert_method_args(selected_abi, args) @@ -436,14 +440,6 @@ def _as_transaction(self, *args) -> ContractTransaction: address=self.contract.address, ) - def _validate_is_contract(self): - if not self.contract.is_contract: - raise ContractNotFoundError( - self.contract.address, - self.provider.network.explorer is not None, - self.provider.network_choice, - ) - class ContractEvent(BaseInterfaceModel): """