From 3949da295bc11643d97422e9f7543d4415f8999f Mon Sep 17 00:00:00 2001 From: BobTheBuidler <70677534+BobTheBuidler@users.noreply.github.com> Date: Mon, 8 Apr 2024 17:58:05 -0400 Subject: [PATCH] feat: use NewType for Contract type hints (#139) --- dank_mids/brownie_patch/contract.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dank_mids/brownie_patch/contract.py b/dank_mids/brownie_patch/contract.py index 05847b77..5b9bc274 100644 --- a/dank_mids/brownie_patch/contract.py +++ b/dank_mids/brownie_patch/contract.py @@ -1,6 +1,6 @@ import functools -from typing import Dict, List, Optional, Union, overload +from typing import Dict, List, NewType, Optional, Union, overload import brownie from brownie.network.contract import (ContractCall, ContractTx, OverloadedMethod, @@ -12,6 +12,11 @@ from dank_mids.brownie_patch.types import ContractMethod, DankContractMethod +EventName = NewType("EventName", str) +LogTopic = NewType("LogTopic", str) +Method = NewType("Method", str) +Signature = NewType("Signature", str) + class Contract(brownie.Contract): """a modified `brownie.Contract` with async and call batching functionalities""" @classmethod @@ -26,6 +31,8 @@ def from_ethpm(cls, *args, **kwargs) -> "Contract": def from_explorer(cls, *args, **kwargs) -> "Contract": # NOTE: just forces type checkers to work return super().from_explorer(*args, **kwargs) + topics: Dict[str, str] + signatures: Dict[Method, Signature] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # get rid of the contract call objects, we can materialize them on a jit basis