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

Skip compiled function singature structure #138

Merged
merged 1 commit into from
Apr 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions ethtx/providers/signature_provider.py
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
import logging
from abc import ABC, abstractmethod
from json import JSONDecodeError
from typing import Dict, List, Any, Iterator, TypedDict, Union, Tuple
from typing import Dict, List, Any, Iterator, TypedDict, Union, Tuple, Optional

import requests

@@ -68,7 +68,8 @@ def get_function(self, signature: str) -> Iterator[SignatureReturnType]:
)

for function in reversed(data):
yield self._parse_text_signature_response(function)
if parsed := self._parse_text_signature_response(function):
yield parsed

def get_event(self, signature: str) -> Iterator[SignatureReturnType]:
if signature == "0x":
@@ -79,7 +80,8 @@ def get_event(self, signature: str) -> Iterator[SignatureReturnType]:
)

for event in reversed(data):
yield self._parse_text_signature_response(event)
if parsed := self._parse_text_signature_response(event):
yield parsed

def url(self, endpoint: str) -> str:
return f"{self.API_URL}/{endpoint}/"
@@ -135,7 +137,7 @@ def _get(
return {}

@staticmethod
def _parse_text_signature_response(data: Dict) -> SignatureReturnType:
def _parse_text_signature_response(data: Dict) -> Optional[SignatureReturnType]:
text_sig = data.get("text_signature", "")

name = text_sig.split("(")[0] if text_sig else ""
@@ -145,6 +147,9 @@ def _parse_text_signature_response(data: Dict) -> SignatureReturnType:
)
if "(" in types:
args = tuple(types[types.find("(") + 1 : types.rfind(")")].split(","))
if any("(" in arg for arg in args):
log.warning("Could not parse signature: %s", text_sig)
return None
else:
args = list(filter(None, types.split(",")))