-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Ens Client #814
Add Ens Client #814
Conversation
from gnosis.eth import EthereumNetwork | ||
|
||
|
||
class EnsClient: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class EnsClient: | |
class EnsClient: | |
""" | |
Resolves Ethereum Name Service domains using ``thegraph`` API | |
""" |
gnosis/eth/clients/ens_client.py
Outdated
self.request_timeout = 5 # Seconds | ||
self.request_session = requests.Session() | ||
|
||
def is_available(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def is_available(self): | |
def is_available(self) -> bool: |
gnosis/eth/clients/ens_client.py
Outdated
return False | ||
|
||
@staticmethod | ||
def domain_hash_to_hex_str(domain_hash: Union[str, bytes, int]) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def domain_hash_to_hex_str(domain_hash: Union[str, bytes, int]) -> str: | |
def domain_hash_to_hex_str(domain_hash: Union[HexStr, bytes, int]) -> HexStr: |
gnosis/eth/clients/ens_client.py
Outdated
return None | ||
|
||
def query_by_domain_hash( | ||
self, domain_hash: Union[str, bytes, int] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self, domain_hash: Union[str, bytes, int] | |
self, domain_hash: Union[HexStr, bytes, int] |
gnosis/eth/clients/ens_client.py
Outdated
|
||
@lru_cache | ||
@cache_memoize(60 * 60 * 24, prefix="ens-_query_by_domain_hash") # 1 day | ||
def _query_by_domain_hash(self, domain_hash_str: str) -> Optional[str]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def _query_by_domain_hash(self, domain_hash_str: str) -> Optional[str]: | |
def _query_by_domain_hash(self, domain_hash_str: HexStr) -> Optional[str]: |
requirements.txt
Outdated
@@ -1,4 +1,5 @@ | |||
django==4.2.10 | |||
django-cache-memoize==0.2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use cache-memoize, standard library should be enough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, is gnosis.util.cache
correct here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's a wrapper around functools.cache
as it was added in Python 3.9 : https://docs.python.org/3/library/functools.html#functools.cache
closes #754