Skip to content

Commit

Permalink
Merge pull request #1115 from moonstream-to/fix-historical-crawl-encode
Browse files Browse the repository at this point in the history
Fix data type.
  • Loading branch information
Andrei-Dolgolev authored Jul 24, 2024
2 parents 4e9980c + b41cf9a commit 36b7ca5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
12 changes: 11 additions & 1 deletion crawlers/mooncrawl/mooncrawl/moonworm_crawler/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,10 @@ def handle_historical_crawl_v3(args: argparse.Namespace) -> None:
f"Initial function call crawl jobs count: {len(initial_function_call_jobs)}"
)

customer_connection = get_db_connection(args.customer_uuid)
if args.customer_uri is not None:
customer_connection = args.customer_uri
else:
customer_connection = get_db_connection(args.customer_uuid)

if customer_connection == "":
raise ValueError("No connection string found for the customer")
Expand Down Expand Up @@ -1083,6 +1086,13 @@ def main() -> None:
help="User UUID",
)

historical_crawl_parser_v3.add_argument(
"--customer-uri",
type=str,
required=False,
help="Customer URI",
)

historical_crawl_parser_v3.set_defaults(func=handle_historical_crawl_v3)

args = parser.parse_args()
Expand Down
13 changes: 9 additions & 4 deletions crawlers/mooncrawl/mooncrawl/moonworm_crawler/db.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import logging
from hexbytes import HexBytes
from typing import Dict, List, Optional, Union, Any

from moonstreamdb.models import Base
Expand Down Expand Up @@ -265,7 +266,9 @@ def add_events_to_session(
"block_timestamp": label_event.block_timestamp,
"caller_address": None,
"origin_address": None,
"address": bytes.fromhex(label_event.address[2:]),
"address": HexBytes(
label_event.address
), # transform to \x00 format on insert
"label_name": label_event.label_name,
"label_type": "event",
"label_data": label_event.label_data,
Expand Down Expand Up @@ -355,9 +358,11 @@ def add_function_calls_to_session(
"block_number": label_function_call.block_number,
"block_hash": label_function_call.block_hash,
"block_timestamp": label_function_call.block_timestamp,
"caller_address": bytes.fromhex(label_function_call.caller_address[2:]),
"origin_address": bytes.fromhex(label_function_call.caller_address[2:]),
"address": bytes.fromhex(label_function_call.address[2:]),
"caller_address": HexBytes(label_function_call.caller_address),
"origin_address": HexBytes(label_function_call.caller_address),
"address": HexBytes(
label_function_call.address
), # transform to \x00 format on insert
"label_name": label_function_call.label_name,
"label_type": "tx_call",
"label_data": label_function_call.label_data,
Expand Down

0 comments on commit 36b7ca5

Please sign in to comment.