Skip to content
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

Merged
merged 7 commits into from
Mar 5, 2024
Merged

Add Ens Client #814

merged 7 commits into from
Mar 5, 2024

Conversation

falvaradorodriguez
Copy link
Contributor

closes #754

from gnosis.eth import EthereumNetwork


class EnsClient:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class EnsClient:
class EnsClient:
"""
Resolves Ethereum Name Service domains using ``thegraph`` API
"""

self.request_timeout = 5 # Seconds
self.request_session = requests.Session()

def is_available(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def is_available(self):
def is_available(self) -> bool:

return False

@staticmethod
def domain_hash_to_hex_str(domain_hash: Union[str, bytes, int]) -> str:
Copy link
Member

@Uxio0 Uxio0 Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:

return None

def query_by_domain_hash(
self, domain_hash: Union[str, bytes, int]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self, domain_hash: Union[str, bytes, int]
self, domain_hash: Union[HexStr, bytes, int]


@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]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Member

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

Copy link
Contributor Author

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?

Copy link
Member

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

@falvaradorodriguez falvaradorodriguez marked this pull request as ready for review March 5, 2024 13:40
@falvaradorodriguez falvaradorodriguez requested a review from a team as a code owner March 5, 2024 13:40
@falvaradorodriguez falvaradorodriguez merged commit e4aeea4 into main Mar 5, 2024
8 checks passed
@falvaradorodriguez falvaradorodriguez deleted the add-ens-client branch March 5, 2024 15:09
@github-actions github-actions bot locked and limited conversation to collaborators Mar 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move safe-transaction-service EnsClient to safe-eth-py
2 participants