-
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add AccountAPI.transfer * feat: support for contract deployment and calls * feat: add ability to load generic contracts * feat: add selector and signature properties to ABI dataclasses * feat: add support for contract interactions * fix: Ensure we don't try to deploy empty bytecode * fix: need to pass address to create transaction; other fixes * fix: handle ABI encoding correctly * lint: ignore mypy error in import * feat: add tab completion for contracts and accounts/addresses * fix: display signature properly * fix: unclosed file handle * refactor: display prettier transaction to sign * refactor: have signing a transaction also return Optional * fix: display strings and generic Exceptions to show full stack * feat: display signature of longest function when showing call handlers * refactor: simplify handler code * refactor: don't export `Contract` helper function * fix: raise internal exception on password mismatch
- Loading branch information
Showing
16 changed files
with
842 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,24 @@ | ||
from .accounts import AccountAPI, AccountContainerAPI | ||
from .address import Address, AddressAPI | ||
from .contracts import ContractLog | ||
from .explorers import ExplorerAPI | ||
from .networks import EcosystemAPI, NetworkAPI, ProviderContextManager, create_network_type | ||
from .providers import ProviderAPI | ||
from .providers import ProviderAPI, ReceiptAPI, TransactionAPI, TransactionStatusEnum | ||
|
||
__all__ = [ | ||
"AccountAPI", | ||
"AccountContainerAPI", | ||
"Address", | ||
"AddressAPI", | ||
"ContractInstance", | ||
"ContractLog", | ||
"EcosystemAPI", | ||
"ExplorerAPI", | ||
"ProviderAPI", | ||
"ProviderContextManager", | ||
"NetworkAPI", | ||
"ReceiptAPI", | ||
"TransactionAPI", | ||
"TransactionStatusEnum", | ||
"create_network_type", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from typing import List, Optional, Type | ||
|
||
from .base import abstractdataclass, abstractmethod | ||
from .providers import ProviderAPI, ReceiptAPI, TransactionAPI | ||
|
||
|
||
@abstractdataclass | ||
class AddressAPI: | ||
_provider: Optional[ProviderAPI] = None | ||
|
||
@property | ||
def provider(self) -> ProviderAPI: | ||
if not self._provider: | ||
raise Exception("Wired incorrectly") | ||
|
||
return self._provider | ||
|
||
@property | ||
def _receipt_class(self) -> Type[ReceiptAPI]: | ||
return self.provider.network.ecosystem.receipt_class | ||
|
||
@property | ||
def _transaction_class(self) -> Type[TransactionAPI]: | ||
return self.provider.network.ecosystem.transaction_class | ||
|
||
@property | ||
@abstractmethod | ||
def address(self) -> str: | ||
... | ||
|
||
def __dir__(self) -> List[str]: | ||
# This displays methods to IPython on `a.[TAB]` tab completion | ||
return [ | ||
"address", | ||
"balance", | ||
"code", | ||
"codesize", | ||
"nonce", | ||
"is_contract", | ||
"provider", | ||
] | ||
|
||
def __repr__(self) -> str: | ||
return f"<{self.__class__.__name__} {self.address}>" | ||
|
||
def __str__(self) -> str: | ||
return self.address | ||
|
||
@property | ||
def nonce(self) -> int: | ||
return self.provider.get_nonce(self.address) | ||
|
||
@property | ||
def balance(self) -> int: | ||
return self.provider.get_balance(self.address) | ||
|
||
@property | ||
def code(self) -> bytes: | ||
# TODO: Explore caching this (based on `self.provider.network` and examining code) | ||
return self.provider.get_code(self.address) | ||
|
||
@property | ||
def codesize(self) -> int: | ||
return len(self.code) | ||
|
||
@property | ||
def is_contract(self) -> bool: | ||
return len(self.code) > 0 | ||
|
||
|
||
class Address(AddressAPI): | ||
_address: str | ||
|
||
@property | ||
def address(self) -> str: | ||
return self._address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.