|
1 | 1 | import asyncio |
2 | 2 | import logging |
3 | 3 | from functools import partial |
4 | | -from typing import Any, Dict, List, Optional, Tuple |
| 4 | +from typing import Any, Dict, List, Optional, Tuple, Union |
5 | 5 |
|
6 | 6 | import aiohttp |
7 | 7 | from signalrcore.hub.base_hub_connection import BaseHubConnection # type: ignore |
|
12 | 12 | from dipdup.config import ROLLBACK_HANDLER, OperationHandlerConfig, OperationIndexConfig |
13 | 13 | from dipdup.datasources.tzkt.cache import OperationCache |
14 | 14 | from dipdup.datasources.tzkt.enums import TzktMessageType |
15 | | -from dipdup.models import HandlerContext, OperationData, State |
| 15 | +from dipdup.models import HandlerContext, OperationContext, OperationData, State |
16 | 16 |
|
17 | 17 | TZKT_HTTP_REQUEST_LIMIT = 10000 |
18 | 18 | TZKT_HTTP_REQUEST_SLEEP = 1 |
@@ -236,19 +236,23 @@ async def on_operation_match( |
236 | 236 | matched_operations: List[OperationData], |
237 | 237 | operations: List[OperationData], |
238 | 238 | ): |
239 | | - args = [] |
| 239 | + handler_context = HandlerContext( |
| 240 | + operations=operations, |
| 241 | + template_values=index_config.template_values, |
| 242 | + ) |
| 243 | + args: List[Union[OperationContext, HandlerContext]] = [handler_context] |
240 | 244 | for pattern_config, operation in zip(handler_config.pattern, matched_operations): |
241 | 245 |
|
242 | 246 | parameter_type = pattern_config.parameter_type_cls |
243 | 247 | parameter = parameter_type.parse_obj(operation.parameter_json) |
244 | 248 |
|
245 | | - context = HandlerContext( |
| 249 | + operation_context = OperationContext( |
246 | 250 | data=operation, |
247 | 251 | parameter=parameter, |
248 | 252 | ) |
249 | | - args.append(context) |
| 253 | + args.append(operation_context) |
250 | 254 |
|
251 | | - await handler_config.callback_fn(*args, operations, index_config.template_values) |
| 255 | + await handler_config.callback_fn(*args) |
252 | 256 |
|
253 | 257 | @classmethod |
254 | 258 | def convert_operation(cls, operation_json: Dict[str, Any]) -> OperationData: |
|
0 commit comments