generated from ApeWorX/project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
45 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,31 @@ | ||
from ape import plugins | ||
from ape.types import AddressType | ||
|
||
from .addressbook import AddressBookConfig, addressbook # noqa: F401 | ||
from .converters import AddressBookConverter | ||
|
||
|
||
@plugins.register(plugins.Config) | ||
def config_class(): | ||
from .addresses import AddressBookConfig | ||
|
||
return AddressBookConfig | ||
|
||
|
||
@plugins.register(plugins.ConversionPlugin) | ||
def converters(): | ||
from ape.types import AddressType | ||
|
||
from .converters import AddressBookConverter | ||
|
||
return AddressType, AddressBookConverter | ||
|
||
|
||
___all__ = [ | ||
"addressbook", | ||
] | ||
def __getattr__(name: str): | ||
if name == "addressbook": | ||
from ape_addressbook.addresses import addressbook | ||
|
||
return addressbook | ||
|
||
import ape_addressbook.addresses as module | ||
|
||
return getattr(module, name) | ||
|
||
|
||
___all__ = ["addressbook"] |
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,14 +1,16 @@ | ||
from typing import Any | ||
from typing import TYPE_CHECKING, Any | ||
|
||
from ape.api.convert import ConverterAPI | ||
from ape.types import AddressType | ||
|
||
from .addressbook import addressbook | ||
from ape_addressbook import addressbook | ||
|
||
if TYPE_CHECKING: | ||
from ape.types import AddressType | ||
|
||
|
||
class AddressBookConverter(ConverterAPI): | ||
def is_convertible(self, value: Any) -> bool: | ||
return isinstance(value, str) and value in addressbook | ||
|
||
def convert(self, alias: str) -> AddressType: | ||
def convert(self, alias: str) -> "AddressType": | ||
return addressbook[alias] |
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,7 +1,9 @@ | ||
[flake8] | ||
max-line-length = 100 | ||
ignore = E704,W503,PYD002,TC003,TC006 | ||
exclude = | ||
venv* | ||
.eggs | ||
docs | ||
build | ||
type-checking-pydantic-enabled = True |
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