Skip to content

Commit

Permalink
tuple[MatchedHandler, ...]
Browse files Browse the repository at this point in the history
  • Loading branch information
droserasprout committed Jan 23, 2025
1 parent d7df4e2 commit 8460083
Show file tree
Hide file tree
Showing 22 changed files with 22 additions and 42 deletions.
2 changes: 1 addition & 1 deletion docs/9.release-notes/3.v8.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ DipDup 8.0 introduces a new `batch` handler to modify higher-level indexing logi
```python [handlers/batch.py]
async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
Expand Down
3 changes: 1 addition & 2 deletions src/demo_blank/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_evm_events/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_evm_transactions/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_evm_uniswap/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_starknet_events/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_substrate_events/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_auction/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_dao/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_dex/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_domains/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_etherlink/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_events/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_factories/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_head/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_nft_marketplace/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_raw/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_token/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_token_balances/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/demo_tezos_token_transfers/handlers/batch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections.abc import Iterable

from dipdup.context import HandlerContext
from dipdup.index import MatchedHandler


async def batch(
ctx: HandlerContext,
handlers: Iterable[MatchedHandler],
handlers: tuple[MatchedHandler, ...],
) -> None:
for handler in handlers:
await ctx.fire_matched_handler(handler)
3 changes: 1 addition & 2 deletions src/dipdup/codegen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,12 @@ class BatchHandlerConfig(HandlerConfig, CallbackMixin):
callback: str = 'batch'

def iter_imports(self, package: str) -> Iterator[tuple[str, str]]:
yield 'collections.abc', 'Iterable'
yield 'dipdup.context', 'HandlerContext'
yield 'dipdup.index', 'MatchedHandler'

def iter_arguments(self) -> Iterator[tuple[str, str]]:
yield 'ctx', 'HandlerContext'
yield 'handlers', 'Iterable[MatchedHandler]'
yield 'handlers', 'tuple[MatchedHandler, ...]'


class _BaseCodeGenerator(ABC):
Expand Down
2 changes: 1 addition & 1 deletion src/dipdup/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async def _process_level_data(
return

started_at = time.time()
batch_handlers = (
batch_handlers = tuple(
MatchedHandler(
index=self,
level=batch_level,
Expand Down

0 comments on commit 8460083

Please sign in to comment.