Skip to content

Commit

Permalink
perf: make faster
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Nov 1, 2024
1 parent 52f3c51 commit 2788079
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/ape/contracts/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import click
from eth_pydantic_types import HexBytes
from eth_utils import to_hex
from ethpm_types.contract_type import ABI_W_SELECTOR_T, ContractType

from ape.api.address import Address, BaseAddress
from ape.api.query import (
Expand Down Expand Up @@ -44,11 +43,10 @@
from ape.utils.misc import log_instead_of_fail

if TYPE_CHECKING:
from ethpm_types.abi import ConstructorABI, ErrorABI
from ethpm_types.abi import ConstructorABI, ErrorABI, EventABI, MethodABI
from ethpm_types.contract_type import ABI_W_SELECTOR_T, ContractType
from pandas import DataFrame

from ethpm_types.abi import EventABI, MethodABI

from ape.api.transactions import ReceiptAPI, TransactionAPI
from ape.types.address import AddressType

Expand Down Expand Up @@ -798,7 +796,7 @@ def poll_logs(


class ContractTypeWrapper(ManagerAccessMixin):
contract_type: ContractType
contract_type: "ContractType"
base_path: Optional[Path] = None

@property
Expand All @@ -810,7 +808,7 @@ def selector_identifiers(self) -> dict[str, str]:
return self.contract_type.selector_identifiers

@property
def identifier_lookup(self) -> dict[str, ABI_W_SELECTOR_T]:
def identifier_lookup(self) -> dict[str, "ABI_W_SELECTOR_T"]:
"""
Provides a mapping of method, error, and event selector identifiers to
ABI Types.
Expand Down Expand Up @@ -924,7 +922,7 @@ class ContractInstance(BaseAddress, ContractTypeWrapper):
def __init__(
self,
address: "AddressType",
contract_type: ContractType,
contract_type: "ContractType",
txn_hash: Optional[Union[str, HexBytes]] = None,
) -> None:
super().__init__()
Expand Down Expand Up @@ -958,7 +956,9 @@ def __call__(self, *args, **kwargs) -> "ReceiptAPI":
return super().__call__(*args, **kwargs)

@classmethod
def from_receipt(cls, receipt: "ReceiptAPI", contract_type: ContractType) -> "ContractInstance":
def from_receipt(
cls, receipt: "ReceiptAPI", contract_type: "ContractType"
) -> "ContractInstance":
"""
Create a contract instance from the contract deployment receipt.
"""
Expand Down Expand Up @@ -1076,7 +1076,7 @@ def call_view_method(self, method_name: str, *args, **kwargs) -> Any:

else:
# Didn't find anything that matches
name = self.contract_type.name or ContractType.__name__
name = self.contract_type.name or "ContractType"
raise ApeAttributeError(f"'{name}' has no attribute '{method_name}'.")

def invoke_transaction(self, method_name: str, *args, **kwargs) -> "ReceiptAPI":
Expand Down Expand Up @@ -1111,7 +1111,7 @@ def invoke_transaction(self, method_name: str, *args, **kwargs) -> "ReceiptAPI":

else:
# Didn't find anything that matches
name = self.contract_type.name or ContractType.__name__
name = self.contract_type.name or "ContractType"
raise ApeAttributeError(f"'{name}' has no attribute '{method_name}'.")

def get_event_by_signature(self, signature: str) -> ContractEvent:
Expand Down Expand Up @@ -1340,7 +1340,7 @@ class ContractContainer(ContractTypeWrapper, ExtraAttributesMixin):
contract_container = project.MyContract # Assuming there is a contract named "MyContract"
"""

def __init__(self, contract_type: ContractType) -> None:
def __init__(self, contract_type: "ContractType") -> None:
self.contract_type = contract_type

@log_instead_of_fail(default="<ContractContainer>")
Expand Down

0 comments on commit 2788079

Please sign in to comment.