pull/919/head
Andrey 2023-09-07 18:04:34 +03:00
rodzic 8502889540
commit 2719d9baba
2 zmienionych plików z 18 dodań i 11 usunięć

Wyświetl plik

@ -538,6 +538,10 @@ def apply_moonworm_tasks(
if "abi_method_hash" in tag
]
existing_selectors = [
tag.split(":")[-1] for tag in chain(*existing_tags) if "abi_selector" in tag
]
abi_hashes_dict = {
hashlib.md5(json.dumps(method).encode("utf-8")).hexdigest(): method
for method in abi
@ -545,17 +549,20 @@ def apply_moonworm_tasks(
and (method.get("stateMutability", "") != "view")
}
abi_selectors_dict = {
Web3.keccak(
text=abi_hashes_dict[hash]["name"]
+ "("
+ ",".join(map(lambda x: x["type"], abi_hashes_dict[hash]["inputs"]))
+ ")"
)[:4].hex(): method
for method in abi
if (method["type"] in ("event", "function"))
and (method.get("stateMutability", "") != "view")
}
for hash in abi_hashes_dict:
if hash not in existing_hashes:
abi_selector = Web3.keccak(
text=abi_hashes_dict[hash]["name"]
+ "("
+ ",".join(
map(lambda x: x["type"], abi_hashes_dict[hash]["inputs"])
)
+ ")"
)[:4].hex()
moonworm_abi_tasks_entries_pack.append(
{
"title": address,

Wyświetl plik

@ -51,7 +51,7 @@ def fill_missing_selectors_in_moonworm_tasks() -> None:
logger.warn(f"Unable to parse abi from task: {task.id}")
continue
if not any([tag.startswith("selector:") for tag in task.tags]):
if not any([tag.startswith("abi_selector:") for tag in task.tags]):
## generate selector
abi_selector = Web3.keccak(
@ -61,7 +61,7 @@ def fill_missing_selectors_in_moonworm_tasks() -> None:
+ ")"
)[:4].hex()
tags.append(f"#selector:{abi_selector}")
tags.append(f"abi_selector:{abi_selector}")
entries_tags.append(
{