Skip to content

Commit

Permalink
- chore(__init__.py): remove unused code for downloading files from G…
Browse files Browse the repository at this point in the history
…itHub

-
- feat(translate.py): add support for skipping installation of files from GitHub
  • Loading branch information
alan890104 committed Sep 16, 2023
1 parent 9ad976b commit 83d3760
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
22 changes: 0 additions & 22 deletions decodex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,6 @@
from . import type
from . import utils

installer.download_github_file(
save_path=str(constant.DECODEX_DIR.joinpath("ethereum", "tags.json")),
org="brianleect",
repo="etherscan-labels",
branch="main",
path="data/etherscan/combined/combinedAllLabels.json",
is_lfs=False,
verify_ssl=False,
use_tempfile=False,
)


installer.download_github_file(
save_path=str(constant.DECODEX_DIR.joinpath("ethereum", "signatures.csv")),
org="Solratic",
repo="function-signature-registry",
branch="main",
path="data/ethereum/func_sign.csv.gz",
is_lfs=True,
verify_ssl=False,
use_tempfile=True,
)

__all__ = [
"convert",
Expand Down
32 changes: 32 additions & 0 deletions decodex/translate/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def __init__(
defis: Union[Iterable[str], Literal["all"]] = "all",
verbose: bool = False,
logger: Logger = None,
skip_install: bool = False,
*args,
**kwargs,
) -> None:
Expand All @@ -91,12 +92,14 @@ def __init__(
logger : Logger, optional
Logger to log error messages, default is None
"""

self.tagger = TaggerFactory.create(tagger) if isinstance(tagger, str) else tagger

self.sig_lookup = (
SignatureFactory.create(fmt=sig_lookup, chain=chain) if isinstance(sig_lookup, str) else sig_lookup
)

self.chain = chain
self.searcher = SearcherFactory.create("web3", uri=provider_uri)
self.mc = Multicall(provider_uri, logger=logger)
self.hdlrs: Dict[str, EventHandleFunc] = {}
Expand All @@ -107,6 +110,35 @@ def __init__(
if logger is None and verbose:
self.logger = Logger(name=self.__class__.__name__)

if not skip_install:
self.install()

def install(self):
from decodex import installer
from decodex import constant

installer.download_github_file(
save_path=str(constant.DECODEX_DIR.joinpath(self.chain, "tags.json")),
org="brianleect",
repo="etherscan-labels",
branch="main",
path="data/etherscan/combined/combinedAllLabels.json",
is_lfs=False,
verify_ssl=False,
use_tempfile=False,
)

installer.download_github_file(
save_path=str(constant.DECODEX_DIR.joinpath(self.chain, "signatures.csv")),
org="Solratic",
repo="function-signature-registry",
branch="main",
path="data/ethereum/func_sign.csv.gz",
is_lfs=True,
verify_ssl=False,
use_tempfile=True,
)

def translate(self, txhash: str, *, max_workers: int = 10) -> TaggedTx:
tx: Tx = self.searcher.get_tx(txhash)
return self._process_tx(tx, max_workers=max_workers)
Expand Down

0 comments on commit 83d3760

Please sign in to comment.