Skip to content

Commit

Permalink
feat: use NewType for Contract type hints (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobTheBuidler authored Apr 8, 2024
1 parent 06caaa4 commit 3949da2
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dank_mids/brownie_patch/contract.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 3949da2

Please sign in to comment.