From ce6ef9f4bde57c5ab3cc2da1724d6fe7891cb657 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 30 Jul 2024 16:40:28 +0300 Subject: [PATCH 1/2] Add multiple addresses --- moonworm/crawler/log_scanner.py | 12 +++++++++--- moonworm/version.py | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/moonworm/crawler/log_scanner.py b/moonworm/crawler/log_scanner.py index 5ee336a..f69d2ff 100644 --- a/moonworm/crawler/log_scanner.py +++ b/moonworm/crawler/log_scanner.py @@ -3,7 +3,7 @@ import json import logging import time -from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple +from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union from eth_abi.codec import ABICodec from eth_typing.evm import ChecksumAddress @@ -135,7 +135,7 @@ def _crawl_events( from_block: int, to_block: int, batch_size: int, - contract_address: ChecksumAddress, + contract_addresses: Union[ChecksumAddress, List[ChecksumAddress]], batch_size_update_threshold: int = 1000, max_blocks_batch: int = 10000, min_blocks_batch: int = 100, @@ -148,6 +148,12 @@ def _crawl_events( events = [] current_from_block = from_block + address_list = ( + [contract_addresses] + if isinstance(contract_addresses, ChecksumAddress) + else contract_addresses + ) # for backwards compatibility + while current_from_block <= to_block: current_to_block = min(current_from_block + batch_size, to_block) try: @@ -156,7 +162,7 @@ def _crawl_events( event_abi, current_from_block, current_to_block, - [contract_address], + address_list, ) events.extend(events_chunk) current_from_block = current_to_block + 1 diff --git a/moonworm/version.py b/moonworm/version.py index 924cd55..855fa77 100644 --- a/moonworm/version.py +++ b/moonworm/version.py @@ -1 +1 @@ -MOONWORM_VERSION = "0.9.2" +MOONWORM_VERSION = "0.9.3" From 52ac773bd56550ec85698ef09afd600e398094bc Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 31 Jul 2024 11:55:24 +0300 Subject: [PATCH 2/2] Add changes. --- moonworm/crawler/log_scanner.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/moonworm/crawler/log_scanner.py b/moonworm/crawler/log_scanner.py index f69d2ff..3cd6adc 100644 --- a/moonworm/crawler/log_scanner.py +++ b/moonworm/crawler/log_scanner.py @@ -135,7 +135,7 @@ def _crawl_events( from_block: int, to_block: int, batch_size: int, - contract_addresses: Union[ChecksumAddress, List[ChecksumAddress]], + contract_address: Union[ChecksumAddress, List[ChecksumAddress]], batch_size_update_threshold: int = 1000, max_blocks_batch: int = 10000, min_blocks_batch: int = 100, @@ -149,9 +149,7 @@ def _crawl_events( current_from_block = from_block address_list = ( - [contract_addresses] - if isinstance(contract_addresses, ChecksumAddress) - else contract_addresses + [contract_address] if isinstance(contract_address, str) else contract_address ) # for backwards compatibility while current_from_block <= to_block: