Skip to content

Commit

Permalink
feat: prepare for cython (#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Nov 16, 2024
1 parent 05210df commit dd1875a
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions dank_mids/brownie_patch/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ def __getattribute__(self, name: str) -> DankContractMethod:
return attr

@functools.cached_property
def __method_names__(self) -> List[str]:
def __method_names__(self) -> Tuple[str, ...]:
"""List of method names defined in the contract ABI."""
return [i["name"] for i in self.abi if i["type"] == "function"]
return tuple(i["name"] for i in self.abi if i["type"] == "function")

def __get_method_object__(self, name: str) -> DankContractMethod:
"""
Expand All @@ -206,12 +206,15 @@ def __get_method_object__(self, name: str) -> DankContractMethod:
from dank_mids import web3

overloaded = self.__method_names__.count(name) > 1
for abi in [i for i in self.abi if i["type"] == "function"]:
if abi["name"] != name:

for abi in self.abi:
if abi["function"] != "function" or abi["name"] != name:
continue

full_name = f"{self._name}.{name}"
sig = build_function_signature(abi)
natspec: Dict = {}

natspec: Dict[str, Any] = {}
if self._build.get("natspec"):
natspec = self._build["natspec"]["methods"].get(sig, {})

Expand All @@ -221,7 +224,9 @@ def __get_method_object__(self, name: str) -> DankContractMethod:
# special logic to handle function overloading
elif overloaded is True:
overloaded = DankOverloadedMethod(self.address, full_name, self._owner)

overloaded._add_fn(abi, natspec)

return overloaded # type: ignore [return-value]


Expand Down

0 comments on commit dd1875a

Please sign in to comment.